import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '订单编号',
    align:"center",
    dataIndex: 'orderCode'
   },
   {
    title: '房间号',
    align:"center",
    dataIndex: 'roomName_dictText'
   },
   {
    title: '会员名称',
    align:"center",
    dataIndex: 'memberName'
   },
   {
    title: '开始时间',
    align:"center",
    dataIndex: 'startTime'
   },
   {
    title: '结束时间',
    align:"center",
    dataIndex: 'endTime'
   },
   {
    title: '订单状态',
    align:"center",
    dataIndex: 'orderStatus_dictText'
   },
   {
    title: '支付方式',
    align:"center",
    dataIndex: 'paymentMethod_dictText'
   },
   {
    title: '订单总额',
    align:"center",
    dataIndex: 'totalAmount'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remark'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "上钟技师",
      field: 'technicianName',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"technician,name,name"
      },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '订单编号',
    field: 'orderCode',
    component: 'Input',
  },
  {
    label: '订单时间',
    field: 'createTime',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
    dynamicDisabled:true
  },
  {
    label: '上钟技师',
    field: 'technicianName',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"technician,name,name"
     },
  },
  {
    label: '按摩项目',
    field: 'anmoProject',
    component: 'JPopup',
    componentProps: ({ formActionType }) => {
        const {setFieldsValue} = formActionType;
        return{
            setFieldsValue:setFieldsValue,
            code:"seeanmoproject",
            fieldConfig: [
                { source: 'anmo_name', target: 'anmoProject' },
                { source: 'price', target: 'totalAmount' },
            ],
            multi:true
        }
    },

  },
  {
    label: '房间号',
    field: 'roomName',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"room,room_name,room_name"
     },
  },
  {
    label: '会员名称',
    field: 'memberName',
    component: 'JPopup',
    componentProps: ({ formActionType }) => {
        const {setFieldsValue} = formActionType;
        return{
            setFieldsValue:setFieldsValue,
            code:"seemember",
            fieldConfig: [
                { source: 'name', target: 'memberName' },
            ],
            multi:true
        }
    },

  },
  {
    label: '开始时间',
    field: 'startTime',
    component: 'TimePicker',
    componentProps: {
      valueFormat: 'HH:mm:ss'
    },
  },
  {
    label: '结束时间',
    field: 'endTime',
    component: 'TimePicker',
    componentProps: {
      valueFormat: 'HH:mm:ss'
    },
  },
  {
    label: '订单状态',
    field: 'orderStatus',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"order_status"
     },
  },
  {
    label: '支付方式',
    field: 'paymentMethod',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"payment_method"
     },
  },
  {
    label: '订单总额',
    field: 'totalAmount',
    component: 'InputNumber',
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  orderCode: {title: '订单编号',order: 0,view: 'text', type: 'string',},
  roomName: {title: '房间号',order: 4,view: 'list', type: 'string',dictTable: "room", dictCode: 'room_name', dictText: 'room_name',},
  memberName: {title: '会员名称',order: 5,view: 'popup', type: 'string',code: 'seemember', orgFields: 'name', destFields: 'memberName', popupMulti: false,},
  startTime: {title: '开始时间',order: 6,view: 'time', type: 'string',},
  endTime: {title: '结束时间',order: 7,view: 'time', type: 'string',},
  orderStatus: {title: '订单状态',order: 8,view: 'list', type: 'string',dictCode: 'order_status',},
  paymentMethod: {title: '支付方式',order: 9,view: 'list', type: 'string',dictCode: 'payment_method',},
  totalAmount: {title: '订单总额',order: 10,view: 'number', type: 'number',},
  remark: {title: '备注',order: 11,view: 'textarea', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}